package com.tencent.iov.cowin.befsale.clue.controller.cus;

import com.tencent.iov.cowin.befsale.clue.controller.cus.assembler.DealerCustomerFollowPlanAssembler;
import com.tencent.iov.cowin.befsale.clue.controller.cus.vo.request.AddCustomerFollowPlanRequest;
import com.tencent.iov.cowin.befsale.clue.controller.cus.vo.request.DeleteDealerCustomerFollowPlanRequest;
import com.tencent.iov.cowin.befsale.clue.controller.cus.vo.request.QueryCustomerFollowPlanRequest;
import com.tencent.iov.cowin.befsale.clue.controller.cus.vo.request.UpdateCustomerFollowPlanRequest;
import com.tencent.iov.cowin.befsale.clue.controller.cus.vo.response.CustomerFollowPlanResponse;
import com.tencent.iov.cowin.befsale.clue.domain.cus.po.DealerCustomerFollowPlan;
import com.tencent.iov.cowin.befsale.clue.service.cus.DealerCustomerFollowPlanService;
import com.software.boot.common.entity.Response;
import com.software.boot.common.model.dao.PageRequest;
import com.software.boot.common.model.dao.PageResponse;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @Describe: 经销商跟进线索表_Controller层
 * @author: xiamu
 * @created: 2021-12-21 17:29:56
 * @version: 1.0
 */
@RestController
@RequestMapping(value = "/v1/demo/dealerCustomerFollowPlan", produces = MediaType.APPLICATION_JSON_VALUE)
@Api(tags = "经销商计划跟进线索表_Controller层")
public class DealerCustomerFollowPlanController {

    @Autowired
    private DealerCustomerFollowPlanService dealerCustomerFollowPlanService;

    /**
     * 通过ID获取详细信息
     *
     * @param: id
     * @return: DealerCustomerFollowPlan对象
     */
    @ApiOperation(value = "DealerCustomerFollowPlan管理-通过ID获取详细信息接口", httpMethod = "GET", response = Response.class, notes = "get_detail_by_id")
    @RequestMapping(path = "/get_detail_by_id", method = RequestMethod.GET)
    public Response<CustomerFollowPlanResponse> getDetailById(@ApiParam(required = true, value = "对象ID", defaultValue = "1") @RequestParam("id") Long id) {
        return Response.success(DealerCustomerFollowPlanAssembler.transformPOToResponseVo(dealerCustomerFollowPlanService.getDetailById(id), CustomerFollowPlanResponse.class));
    }

    /**
     * 单条数据插入DealerCustomerFollowPlan
     *
     * @param request
     * @return 插入的条数
     */
    @ApiOperation(value = "DealerCustomerFollowPlan管理-添加信息接口", httpMethod = "POST", response = Response.class, notes = "add")
    @RequestMapping(path = "/add", method = RequestMethod.POST)
    public Response<Long> add(@Valid @RequestBody AddCustomerFollowPlanRequest request) {
        return Response.success(dealerCustomerFollowPlanService.insert(request));
    }

    /**
     * 批量插入DealerCustomerFollowPlan
     *
     * @param requests
     * @return 批量插入的条数
     */
    @ApiOperation(value = "DealerCustomerFollowPlan管理-批量插入DealerCustomerFollowPlan接口", httpMethod = "POST", response = Response.class, notes = "add_batch")
    @RequestMapping(path = "/add_batch", method = RequestMethod.POST)
    public Response<Integer> addBatch(@Valid @RequestBody List<AddCustomerFollowPlanRequest> requests) {
        return Response.success(dealerCustomerFollowPlanService.insertBatch(requests));
    }

    /**
     * 通过ID修改信息接口
     *
     * @param: request
     * @return: 修改的条数
     */
    @ApiOperation(value = "DealerCustomerFollowPlan管理-修改信息接口", httpMethod = "POST", response = Response.class, notes = "update")
    @RequestMapping(path = "/update", method = RequestMethod.POST)
    public Response<Integer> update(@Valid @RequestBody UpdateCustomerFollowPlanRequest request) {
        return Response.success(dealerCustomerFollowPlanService.update(request));
    }

    /**
     * 通过ID删除数据
     *
     * @param request
     * @return 删除的条数
     */
    @ApiOperation(value = "DealerCustomerFollowPlan管理-通过ID删除接口", httpMethod = "POST", response = Response.class, notes = "delete")
    @RequestMapping(path = "/delete", method = RequestMethod.POST)
    public Response<Integer> delete(@Valid @RequestBody DeleteDealerCustomerFollowPlanRequest request) {
        return Response.success(dealerCustomerFollowPlanService.delete(request));
    }

    /**
     * 根据条件查询对象list列表
     *
     * @param request
     * @return 查询结果
     */
    @ApiOperation(value = "DealerCustomerFollowPlan管理-根据条件查询对象list列表接口", httpMethod = "POST", response = Response.class, notes = "query_list_by_param")
    @RequestMapping(path = "/get_list_by_param", method = RequestMethod.POST)
    public Response<List<CustomerFollowPlanResponse>> getListByParam(@RequestBody QueryCustomerFollowPlanRequest request) {
        List<DealerCustomerFollowPlan> responseList = dealerCustomerFollowPlanService.getListByParam(request);
        return Response.success(DealerCustomerFollowPlanAssembler.transformPOToResponseVoList(responseList, CustomerFollowPlanResponse.class));
    }

    /**
     * 根据条件查询对象Page记录
     *
     * @param request
     * @return 查询结果
     */
    @ApiOperation(value = "DealerCustomerFollowPlan管理-根据条件查询对象Page记录接口", httpMethod = "POST", response = Response.class, notes = "get_page_by_param")
    @RequestMapping(value = "/get_page_by_param", method = RequestMethod.POST)
    public Response<PageResponse<CustomerFollowPlanResponse>> getPageByParam(@RequestBody PageRequest<QueryCustomerFollowPlanRequest> request) {
        PageResponse<DealerCustomerFollowPlan> dealerCustomerFollowPlanPageResponse = dealerCustomerFollowPlanService.getPageByParam(request);
        return Response.success(DealerCustomerFollowPlanAssembler.transformPOToResponseVoPage(dealerCustomerFollowPlanPageResponse, CustomerFollowPlanResponse.class));
    }

    /**
     * 根据条件查询单个对象
     *
     * @param request
     * @return 查询结果
     */
    @ApiOperation(value = "DealerCustomerFollowPlan管理-根据条件查询单个对象接口", httpMethod = "POST", response = Response.class, notes = "get_page_by_param")
    @RequestMapping(value = "/get_one_by_param", method = RequestMethod.POST)
    public Response<CustomerFollowPlanResponse> getOneByParam(@RequestBody QueryCustomerFollowPlanRequest request) {
        return Response.success(dealerCustomerFollowPlanService.getOneByParam(request));
    }
}